# pluginTest 目录的 CMakeLists.txt

# 收集 pluginTest 目录下的所有测试源文件
file(GLOB_RECURSE PLUGIN_TEST_SOURCES "*.hpp" "*.cpp")

# 创建测试套件
add_executable(pluginTestSuite ${PLUGIN_TEST_SOURCES})

# 根据 GoogleTest 源自何处，使用不同的链接方式
if(GTest_FOUND)
    # 使用系统安装的 Google Test
    target_link_libraries(pluginTestSuite
        PRIVATE
        GTest::GTest
        GTest::Main
        plugin_lib
        common_lib
        ${Boost_LIBRARIES}
    )
else()
    # 使用项目内配置的 Google Test
    target_link_libraries(pluginTestSuite
        PRIVATE
        gtest
        gtest_main
        plugin_lib
        common_lib
        ${Boost_LIBRARIES}
    )
endif()

# 设置包含目录
target_include_directories(pluginTestSuite
    PRIVATE
    ${CMAKE_SOURCE_DIR}/src/plugin/include
    ${CMAKE_SOURCE_DIR}/src/common/include
)

# 将测试归类
set_target_properties(pluginTestSuite PROPERTIES FOLDER "Tests/PluginTests")

include(GoogleTest)
# 添加为测试
gtest_discover_tests(pluginTestSuite)
